// SVG进度
const svgs = document.querySelectorAll('svg.progress');
// 遍历每个SVG元素并根据aria-label值添加样式
svgs.forEach(svg => {
    const ariaLabelValue = svg.getAttribute('aria-label');
    const rects = svg.querySelectorAll('rect');
    const firstRect = svg.querySelector('rect:nth-child(1)');
    const secondRect = svg.querySelector('rect:nth-child(3)');
    const polygon = svg.querySelector('polygon');
    if (ariaLabelValue === '100') {
        rects.forEach(rect => {
            rect.classList.add('bar');
        });
        polygon.classList.add('bar');
    } else if (parseInt(ariaLabelValue) >= 80 && parseInt(ariaLabelValue) <= 99) {
        rects.forEach(rect => {
            rect.classList.add('bar');
        });
    } else if (parseInt(ariaLabelValue) >= 30 && parseInt(ariaLabelValue) <= 79) {
        rects.forEach(rect => {
            firstRect.classList.add('bar');
            secondRect.classList.add('bar');
        });
    } else if (parseInt(ariaLabelValue) >= 1 && parseInt(ariaLabelValue) <= 29) {
        rects.forEach(rect => {
            secondRect.classList.add('bar');
        });
    }
});
$('.title h1').text($('.page-sidebar .active p').text()+'：'+$('.page-sidebar .active h4').text());
for (var i = $('.practice').length - 1; i >= 0; i--) {
    if ($($('.practice')[i]).find('li').length == 0){
        $($('.practice')[i]).remove();
    }
}
var checkHeight = $(".page-sidebar .active").offset().top;
var heightW = $(window).height();
console.log(checkHeight,heightW);
if (checkHeight > (heightW/2)) {
    $('.page-sidebar').animate({ scrollTop:checkHeight - (heightW/2)}, 100);
}